/*
 * UIEngine.h
 */

#ifndef UIENGINE_H_
#define UIENGINE_H_

#include <string>
#include <list>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include "UIComponent.h"

/**
 * Defines all the primitives needed to draw simple UI with OpenGL
 */
class UIEngine {

public:
  /**
   * Constructor for UI components with colored background
   * @param background default background color for UI Components
   * @param border default border color for UI components
   * @param width default width for top containers such as UIWindow
   * @param height default height for top containers such as UIWindow
   * @param borderSize default border size for UI Composite Components
   * @param rounding default corner rounding for UI Composite Components
   */
  UIEngine(RGBAColor background, RGBAColor border, float width, float height,
      float borderSize = 0.001, float rounding = 0.01);

  /**
   * Destructor cleans up all allocated memory,
   * especially if there are loaded textures
   */
  ~UIEngine();

  /**
   * Registers an UI Component to the list
   * @param uic the UI Component to be added to the list
   */
  void addUIComponent(UIComponent* uic);

  /**
   * Unregisters an UI Component from the list
   * @param uic the UI Component to be removed from the list
   */
  void removeUIComponent(UIComponent* uic);

  /**
   * Displays all registered UI Components
   */
  void display();

private:

  /**
   * default background color for rendering UI components
   */
  RGBAColor _colorBackground;

  /**
   * default border color for rendering UI components
   */
  RGBAColor _colorBorder;

  /**
   * default width for top containers
   */
  float _widthTopContainer;

  /**
   * default height for top containers
   */
  float _heightTopContainer;

  /**
   * border size for UI composite components
   */
  float _borderSize;

  /**
   * rounding corners for UI composite components
   */
  float _roundingCorner;

  /**
   * the list containing all the UI Components to be drawn
   */
  std::list<UIComponent*> _uiComponents;

  /**
   * Current depth value to be apply to the next added UI Component
   */
  float _currentDepth;

  /**
   * Display list used to render all the component once
   */
  GLuint _dlist;
};

#endif /* UIENGINE_H_ */
